<%-- 
    Document   : index
    Created on : Oct 27, 2009, 11:25:07 PM
    Author     : Johnathon Tieman
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN"
   "http://www.w3.org/TR/html4/strict.dtd">

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="java.util.List" %>
<%@ page import="jhu.profiteer.data.Commodity" %>
<%@ page import="jhu.profiteer.data.CommodityJpaController" %>

<%@ include file="/WEB-INF/jspf/admin/auth.jspf" %>
<html>
  <%
    String pageTitle = "Administration Homepage - Commodities";
    String cssFile = "/profiteer-game/css/profiteer.css";
  %>
  <%@ include file="/WEB-INF/jspf/admin/header.jspf" %>
  <body>
    <%@ include file="/WEB-INF/jspf/title.jspf" %>
    <div class="contentArea Body">
      <div class="pagetitle">Administration</div>
      <div class="pagebody">
        <table>
          <tr>
            <td id="menu"><%@ include file="/WEB-INF/jspf/admin/sidebar.jspf" %></td>
            <td>
              <div class="divround">
                <%@ include file="/WEB-INF/jspf/admin/notice.jspf" %>
                <%
                  CommodityJpaController jc = new CommodityJpaController();
                  List<Commodity> commodities = jc.findCommodityEntities();

                  if(0 == commodities.size())
                  {
                %>
                  <p>There are no commodities available!</p>
                <%
                  }
                  else
                  {
                %>
                <form action="process">
                  <table>
                    <tr>
                      <th id="left">Name</th>
                      <th id="left">Description</th>
                    </tr>
                    <%
                      for(Commodity c : commodities)
                      {
                    %>
                    <tr>
                      <td><a href="commodity?commodityId=<%= c.getId() %>"><%= c.getName() %></a></td>
                      <td><%= c.getDescription() %></td>
                      <td><form action="processCommodity?commodityId=<%= c.getId() %>" method="post"><input type="submit" name="submit" value="Delete" /></form></td>
                    </tr>
                    <% } %>
                  </table>
                </form>
                <%
                  }
                %>
                <a href="commodity">Add Commodity</a>
              </div>
            </td>
          </tr>
        </table>
      </div>
    </div>
    <%@ include file="/WEB-INF/jspf/footer.jspf" %>
  </body>
</html>